package com.xiaoerkeji.eshop.request;


import android.text.TextUtils;

import com.lt.common.DeviceUuidFactory;
import com.lt.system.DateTimeHelper;
import com.xiaoerkeji.eshop.utils.JsonHelper;
import com.xiaoerkeji.eshop.xeApp;
import com.xiaoerkeji.eshop.xeConstant;
import com.xiaoerkeji.eshop.xeSetting;
import com.lt.listener.DataServiceListener;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Request;
import okhttp3.RequestBody;

public class httpRequest extends BaseHttpRequest implements UrlConfig
{


    public httpRequest(DataServiceListener listener)
    {
        super(listener);
    }

    @Override
    protected long getTimeoutMillis()
    {
        return 1000 * 10;
    }

    @Override
    protected Request formatHeaderRequest(Request.Builder builder)
    {
//        builder = builder.addHeader("Accept", "application/json, text/plain, */*")
//                .addHeader("Content-Type", "Content-Type");
        builder = builder.addHeader("client_id", xeApp.getInstance().clientId)
                .addHeader("app_ver", xeApp.getInstance().appVer)
                .addHeader("system_ver", xeApp.getInstance().systemVer)
                .addHeader("create_time", DateTimeHelper.getInstance().formatSimpleTime())
                .addHeader("system_info", xeApp.getInstance().systemInfo);
        return builder.build();
    }

    /**
     * 添加分页数据
     */
    public static void addPageParams(Map<String, Object> map, int pageNo)
    {
        map.put("pageNo", pageNo);
        map.put("pageSize", xeConstant.PAGE_SIZE);
    }

    public void login(final int what, String account, String pwd)
    {
        Map<String, Object> map = new HashMap<>();
        map.put("ak", account);
        map.put("sk", pwd);
        map.put("type", "1");
        postJson(what, api_login, JsonHelper.toJson(map));
    }

    public void info(final int what)
    {
        get(what, api_info);
    }
}
